package com.mp.approvalreq.servlet;

import com.mp.approvalreq.entity.dto.GlobalSettingDTO;
import com.mp.approvalreq.service.SelectApprovalServicePrx;
import com.mp.approvalreq.util.ServiceUtils;
import com.mp.user.entity.User;
import com.plusmoney.message.Message;
import com.plusmoney.message.SuccessMsg;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/getGlobalSetting")
public class GetGlobalSetting extends AbstractServlet {
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			User user = getReqUser(req);
			
			SelectApprovalServicePrx selectApprovalService = ServiceUtils.getSelectApprovalServicePrx();
			GlobalSettingDTO globalSettingDTO = selectApprovalService.getGlobalSetting(user.getCompanyId());
			
			Message.printJson(resp, SuccessMsg.getDefaultMsg(globalSettingDTO));
		} catch (Throwable e) {
			onThrowable(req, resp, e);
		}
	}
}
